﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using ExtBusiness;
using System.Configuration;
using System.Web.Security;
using WF_Business;
using ExtBusiness.FlowOperation;
using System.Net;
using ExtBusiness.Interface;
using ExtBusiness.Common;

public partial class office_RequestUpdateTask : PageBase
{
    ClsSubmitInfo clsSubmit = new ClsSubmitInfo();
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindFlowName();
            BindUtInfo();
        }
    }


    /// <summary>
    /// 绑定该用户有权限的流程名称
    /// </summary>
    /// <!--addby zhongjian 20100105-->
    public void BindFlowName()
    {
        if (Session["UserId"] != null)
        {
            ClsWorkFlow newWorkflow = new ClsWorkFlow();
            DataTable dtTable = newWorkflow.GetWorkFlowByUserId(Session["UserId"].ToString(), "");
            ddlFlow.Items.Clear();
            ddlFlow.Items.Add(new ListItem("所有流程", ""));
            foreach (DataRow row in dtTable.Rows)
            {
                ddlFlow.Items.Add(new ListItem(row["wname"].ToString(), row["wname"].ToString()));
            }
        }
    }

    
    /// <summary>
    /// 绑定待处理业务数据
    /// </summary>
    protected void BindUtInfo()
    {
        DataTable dt = clsSubmit.GetDaiBanInfoForBg();
        gridviewCar.DataSource = dt;
        gridviewCar.RecordCount = dt.Rows.Count;
        gridviewCar.DataBind();
    }

    /// <summary>
    /// datagrid数据加载
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void recvgrid_OnLoadData(object sender, EventArgs e)
    {
        this.BindUtInfo();
    }

    protected void btnQuery_Click(object sender, EventArgs e)
    {
        BindUtInfo();
    }

    #region 行创建
    /// <summary>
    /// 行创建
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gridviewCar_RowCreated(object sender, GridViewRowEventArgs e)
    {
        switch (e.Row.RowType)
        {
            case DataControlRowType.Header:
                break;
            case DataControlRowType.DataRow:
                string strID = string.Empty;
                DataRowView rowView = e.Row.DataItem as DataRowView;
                if (rowView != null)
                {
                    HyperLink hlBg = e.Row.FindControl("hlBg") as HyperLink;
                    HyperLink hlYq = e.Row.FindControl("hlYq") as HyperLink;
                    HyperLink hlCx = e.Row.FindControl("hlCx") as HyperLink;

                    if (hlBg != null)
                    {
                        if (rowView["SUBMITFLAG"].ToString() == "3")//预审状态
                        {
                            WorkFlowPubSettting wfps = new WorkFlowPubSettting();

                            if (rowView["is_bg"].ToString() == "2")//变更状态
                            {
                                hlBg.NavigateUrl = string.Format("OnlineNewTask.aspx?iid={0}&UserName={1}&FlowName={2}",
                                    rowView["iid"], rowView["requester"],  "地图审核变更审批");
                            }
                            else
                            {
                                hlBg.Enabled = false;
                            }

                            if (rowView["is_yq"].ToString() == "2")//延期状态
                            {
                                hlYq.NavigateUrl = string.Format("OnlineNewTask.aspx?iid={0}&UserName={1}&FlowName={2}",
                                   rowView["iid"], rowView["requester"], "地图审核延期审批");
                            }
                            else
                            {
                                hlYq.Enabled = false;
                            }

                            if (rowView["is_cx"].ToString() == "2")//撤销状态
                            {
                                hlCx.NavigateUrl = string.Format("OnlineNewTask.aspx?iid={0}&UserName={1}&FlowName={2}",
                                   rowView["iid"], rowView["requester"], "地图审核撤销审批");
                            }
                            else
                            {
                                hlCx.Enabled = false;
                            }
                        }
                        else
                        {
                            hlBg.Visible = false;
                            hlYq.Visible = false;
                            hlCx.Visible = false;
                        }
                    }
                }
               
                break;
        }
    }
    #endregion

}
